class GenericNumber<T> {
  zeroValue: T;
  add: (x: T, y: T) => T;
}

let myGenericNumber = new GenericNumber<number>();
myGenericNumber.zeroValue = 0;
myGenericNumber.add = function (x, y) {
  return x + y;
};

myGenericNumber.add(13, 23);


// new GenericNumber<string>();
// 这里的 T 填入了 string ，那么 zeroValue，x，y 都必须是 string，返回值也必须是 string。
let myGenericNumber2 = new GenericNumber<string>();
myGenericNumber2.zeroValue = '123';
myGenericNumber2.add = function (x, y) {
  return x + y;
};

myGenericNumber2.add('123', '123')